package com.visikard.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;

import com.visikard.item.ItemAudienceKard;

public class GetAudienceFriendsResponse extends BaseResponse {
	private List<ItemAudienceKard> listItemAudienceKards;

	public List<ItemAudienceKard> getListItemAudienceKards() {
		return listItemAudienceKards;
	}

	public void setListItemAudienceKards(List<ItemAudienceKard> listItemAudienceKards) {
		this.listItemAudienceKards = listItemAudienceKards;
	}

	@Override
	public void extractDataFromServer(String response) throws JSONException {
		super.extractDataFromServer(response);
		// response OK
		if (errorCode == SUCCESS) {
			JSONArray jsArr = getDataJArray(response);
			List<ItemAudienceKard> listItems = new ArrayList<ItemAudienceKard>();
			for (int i = 0; i < jsArr.length(); i++) {
				ItemAudienceKard item = new ItemAudienceKard(jsArr.getJSONObject(i));
				listItems.add(item);
			}
			listItemAudienceKards = listItems;
		}

	}

}
